package com.xiyuan.smartutils;

import com.xiyuan.smartutils.control.Handler;
import com.xiyuan.smartutils.control.HandlerController;

/**
 * 默认多线程处理器
 *
 * @author xiyuan-lgz 2025-06-22 @version v1.0.0 新建与整理
 */
public class Handlers {
    private static final HandlerController controller = new HandlerController(Handlers.class.getName());
    
    static {
        if (controller != null && !controller.isRunning()) {
            controller.setDaemon(true);
            controller.init(0, 1, 10, 999999999);
            controller.start();
        }
    }
    
    public static <T> void addHandler(Class<T> req, Handler<T> handler) {
        controller.addHandler(req, handler);
    }
    
    public static void removeHandler(Class<?> req) {
        controller.removeHandler(req);
    }
    
    
    public static <T> boolean execute(Runnable command) {
        return controller.execute(command);
    }
}
